<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>镜像站@Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/admin/plugin/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->

    <!--引入 element-ui 的样式，-->
    <link rel="stylesheet" href="/admin/plugin/element-ui/index.css">
    <!-- 必须先引入vue，  后使用element-ui -->
    <script type="text/javascript" src="/admin/js-css/js/vue.min.js"></script>
    <!-- 引入element 的组件库-->
    <script type="text/javascript" src="/admin/plugin/element-ui/index.js"></script>

    <script type="text/javascript" src="/admin/js-css/js/mx1.0.js?v=1.3"></script>
    <script src="/admin/js-css/js/axios.min.js" ></script>

	<link rel="stylesheet" href="/admin/js-css/css/backColor.css" media="all">
    <style type="text/css">
        .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
            margin-bottom: 6px;
        }

        .layui-table-click {
            background-color:cadetblue !important;
            color:white;
        }

        ::-webkit-scrollbar {
            width: 6px;
            height: 10px;
            background-color: rgba(255, 255, 255, 0.1);
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(144, 147, 153, .3);
            border-radius: 4px;
            cursor: pointer;
        }
        .layui-form-label {
            float: left;
            display: block;
            padding: 7px 1px;
            width: 100px;
            font-weight: 400;
            line-height: 14px;
            text-align: right;
        }

        /**输入框高度设置**/
        .layui-input, .layui-select, .layui-textarea {
            height: 30px;
            line-height: 30px\9;
        }
        /**按钮样式设置**/
        .layui-btn {
            height: 30px;
            line-height: 30px;
            font-size: 13px;
        }
        .layui-btn+.layui-btn {
            margin-left: 0px;
        }

        .layui-table, .layui-table-view {
            margin: 0px 0;
        }

        .changeLHight .el-form-item__label{
            line-height: 16px !important;
        }


        /**列表内容超出自动换行**/
        /*.layui-table-cell {
            height: auto;
            overflow:visible;white-space:normal;text-overflow:clip;
            word-break: break-all;
        }*/
    </style>
</head>
<body>

<script type="text/html" id="img-mktp">
    {{
    let imgs = d.mktp.split(",");
    for()
    }}

    <div><img src="{{d.mktp}}" width="30px" height="30px"/></div>
</script>

<div id="app">



    <div class="demoTable" style="padding: 5px;">
        <el-form :inline="true" size="small"   ref="listSearch"  >
            <el-form-item :label="item.lable+'：'" v-for="(item,index) in listSearch" :style="'display:'+item.isHide" >
                <!--模糊搜索-->
                <template  v-if="item.gs == '' || item.gs=='0' || item.gs=='4' || item.gs == '6'"  >

                    <template v-if="item.type == '0'">
                        <el-input style="width:180px" v-model="searchInputDtos[item.key].value"  ></el-input>
                    </template>

                    <!--下拉框多选-->
                    <template v-if="item.type == '6' || item.type=='8'" >
                        <el-select  multiple
                                    filterable style="width:180px"
                                    v-model="searchInputDtos[item.key].values"  >
                            <el-option value="" ></el-option>
                            <el-option :value="vm.value"  :label="vm.showValue" v-for="vm in item.searchTypeForSelectDtos">{{vm.showValue}}</el-option>
                        </el-select>
                    </template>

                    <template v-if="item.type == '11'" >
                        <el-cascader  :ref="item.key" size="mini" @change="handleChange(item.key)" clearable
                                      v-model="searchInputDtos[item.key].value"  :props="cascaderProps[item.key]"
                        ></el-cascader>
                    </template>

                    <!--日期框-->
                    <template v-if="item.type == '1'">
                        <el-date-picker value-format="yyyy-MM-dd"
                                        v-model="searchInputDtos[item.key].value"  style="width:180px"
                                        type="date" >
                        </el-date-picker>
                    </template>

                    <!--日期框时分秒-->
                    <template v-if="item.type == '5'">
                        <el-date-picker value-format="yyyy-MM-dd HH:mm:ss"
                                        v-model="searchInputDtos[item.key].value"  style="width:180px"
                                        type="datetime" >
                        </el-date-picker>
                    </template>

                </template>

                <!--大于小于输入框-->
                <template  v-if="item.gs=='1'"  >
                    <template v-if="item.type == '0'">
                        <el-input style="width:180px"  v-model="searchInputDtos[item.key].searchTypeForDateDto.start"  ></el-input>
                        <el-input style="width:180px"  v-model="searchInputDtos[item.key].searchTypeForDateDto.end"  ></el-input>
                    </template>

                    <!--下拉框多选-->
                    <template v-if="item.type == '6' || item.type=='8'" >
                        <el-select filterable style="width:180px"
                                    v-model="searchInputDtos[item.key].searchTypeForDateDto.start" >
                            <el-option value="" ></el-option>
                            <el-option :value="vm.value" :label="vm.showValue" v-for="vm in item.searchTypeForSelectDtos">{{vm.showValue}}</el-option>
                        </el-select>

                        <el-select  filterable style="width:180px"
                                    v-model="searchInputDtos[item.key].searchTypeForDateDto.end" >
                            <el-option value="" ></el-option>
                            <el-option :value="vm.value" :label="vm.showValue" v-for="vm in item.searchTypeForSelectDtos">{{vm.showValue}}</el-option>
                        </el-select>
                    </template>

                    <template v-if="item.type == '11'" >
                        <el-cascader  :ref="item.key" size="mini" @change="handleChange(item.key)" clearable
                                      v-model="searchInputDtos[item.key].searchTypeForDateDto.start" :props="cascaderProps[item.key]"
                        ></el-cascader>
                        <el-cascader  :ref="item.key" size="mini" @change="handleChange(item.key)" clearable
                                      v-model="searchInputDtos[item.key].searchTypeForDateDto.end" :props="cascaderProps[item.key]"
                        ></el-cascader>
                    </template>

                    <!--日期框-->
                    <template v-if="item.type == '1'">
                        <el-date-picker value-format="yyyy-MM-dd"
                                        v-model="searchInputDtos[item.key].searchTypeForDateDto.start" style="width:180px"
                                        type="date" >
                        </el-date-picker>
                        <el-date-picker value-format="yyyy-MM-dd"
                                        v-model="searchInputDtos[item.key].searchTypeForDateDto.end" style="width:180px"
                                        type="date" >
                        </el-date-picker>
                    </template>

                    <!--日期框时分秒-->
                    <template v-if="item.type == '5'">
                        <el-date-picker value-format="yyyy-MM-dd HH:mm:ss"
                                        v-model="searchInputDtos[item.key].searchTypeForDateDto.start" style="width:180px"
                                        type="datetime" >
                        </el-date-picker>
                        <el-date-picker value-format="yyyy-MM-dd HH:mm:ss"
                                        v-model="searchInputDtos[item.key].searchTypeForDateDto.end" style="width:180px"
                                        type="datetime" >
                        </el-date-picker>
                    </template>

                </template>

                <!--大于条件-->
                <template  v-if="item.gs=='2'"  >
                    <template v-if="item.type == '0'">
                        <el-input style="width:180px"  v-model="searchInputDtos[item.key].searchTypeForDateDto.start"  ></el-input>
                    </template>

                    <!--下拉框多选-->
                    <template v-if="item.type == '6' || item.type=='8'" >
                        <el-select filterable style="width:180px"
                                    v-model="searchInputDtos[item.key].searchTypeForDateDto.start" >
                            <el-option value="" ></el-option>
                            <el-option :value="vm.value" :label="vm.showValue" v-for="vm in item.searchTypeForSelectDtos">{{vm.showValue}}</el-option>
                        </el-select>
                    </template>

                    <template v-if="item.type == '11'" >
                        <el-cascader  :ref="item.key" size="mini" @change="handleChange(item.key)" clearable
                                      v-model="searchInputDtos[item.key].searchTypeForDateDto.start" :props="cascaderProps[item.key]"
                        ></el-cascader>
                    </template>

                    <!--日期框-->
                    <template v-if="item.type == '1'">
                        <el-date-picker value-format="yyyy-MM-dd"
                                        v-model="searchInputDtos[item.key].searchTypeForDateDto.start" style="width:180px"
                                        type="date" >
                        </el-date-picker>
                    </template>

                    <!--日期框时分秒-->
                    <template v-if="item.type == '5'">
                        <el-date-picker value-format="yyyy-MM-dd HH:mm:ss"
                                        v-model="searchInputDtos[item.key].searchTypeForDateDto.start" style="width:180px"
                                        type="datetime" >
                        </el-date-picker>
                    </template>

                </template>

                <!--小于条件-->
                <template  v-if="item.gs=='3'"  >
                    <template v-if="item.type == '0'">
                        <el-input style="width:180px"  v-model="searchInputDtos[item.key].searchTypeForDateDto.end"  ></el-input>
                    </template>

                    <!--下拉框多选-->
                    <template v-if="item.type == '6' || item.type=='8'" >

                        <el-select  filterable style="width:180px"
                                    v-model="searchInputDtos[item.key].searchTypeForDateDto.end" >
                            <el-option value="" ></el-option>
                            <el-option :value="vm.value"  :label="vm.showValue" v-for="vm in item.searchTypeForSelectDtos">{{vm.showValue}}</el-option>
                        </el-select>
                    </template>

                    <template v-if="item.type == '11'" >
                        <el-cascader  :ref="item.key" size="mini" @change="handleChange(item.key)" clearable
                                      v-model="searchInputDtos[item.key].searchTypeForDateDto.end" :props="cascaderProps[item.key]"
                        ></el-cascader>
                    </template>

                    <!--日期框-->
                    <template v-if="item.type == '1'">
                        <el-date-picker value-format="yyyy-MM-dd"
                                        v-model="searchInputDtos[item.key].searchTypeForDateDto.end" style="width:180px"
                                        type="date" >
                        </el-date-picker>
                    </template>

                    <!--日期框时分秒-->
                    <template v-if="item.type == '5'">
                        <el-date-picker value-format="yyyy-MM-dd HH:mm:ss"
                                        v-model="searchInputDtos[item.key].searchTypeForDateDto.end" style="width:180px"
                                        type="datetime" >
                        </el-date-picker>
                    </template>

                </template>
            </el-form-item>

        </el-form>

        <template v-if="JSON.stringify(listSearch) != '{}'">
            <button class="layui-btn"  onclick="vm.f_search_simp()">搜索</button>
            <button class="layui-btn"  onclick="vm.f_search_advanced()">高级检索</button>
            <button class="layui-btn"  onclick="vm.f_search_custom()">自定义搜索</button>
        </template>


    </div>

    <div class="layui-btn-group" style="margin-bottom: 4px;" >
        <!--<button type="button"   class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_add()">
            新增
        </button>

        <button type="button"   class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_update()">修改</button>
        <button type="button"   class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_delete()">删除</button>
        -->

        <span v-for="item in buttons" style="margin-right: 4px;" >
            <template v-if="item.custom_data_zygl_id.indexOf(keycode)!=-1">

                <button type="button"  v-if="item.type == 0" :item="JSON.stringify(item)" class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_add(this)">{{item.name}}</button>
                <button type="button"  v-if="item.type == 1" :item="JSON.stringify(item)" up=true  class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_update(this)">{{item.name}}</button>
                <button type="button"  v-if="item.type == 2" :item="JSON.stringify(item)" class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_delete(this)">{{item.name}}</button>
                <button type="button"  v-if="item.type == 3" :item="JSON.stringify(item)"  class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_post_confirm(this)">{{item.name}}</button>
                <button type="button"  v-if="item.type == 4" class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_set_list()">列表自定义</button>
                <button type="button"  v-if="item.type == 5" class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_set_input()">录入自定义</button>
                <button type="button"  v-if="item.type == 6" class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_set_order()">排序自定义</button>
                <button type="button"  v-if="item.type == 7" :item="JSON.stringify(item)" class="layui-btn layui-btn-normal layui-btn-sm" onclick="vm.f_exp(this)">{{item.name}}</button>

            </template>

            <template v-else>
                <button type="button"  :item="JSON.stringify(item)"  class="layui-btn layui-btn-normal layui-btn-sm" @click="vm.callFunModule(item.custom_data_zygl_id)" size="small" >{{item.name}}</button>
            </template>

        </span>



    </div>

    <table id="demo" lay-filter="test"></table>
</div>


<script src="/admin/plugin/layui/dist/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>
    var table = null;
    var $ = null;

    var vm = new Vue({
        el: '#app',
        data: {
            listSearch: {}//默认查询的字段
            , searchInputDtos: {},
            buttons: [],
            mapzygl:{},
            dataid:"",
            cascaderProps:{},//三级联动动态加载
            parmsData:{},
            keycode:"",
        },
        created() {
            this.parmsData = getParams();
            if(this.parmsData.tableId != undefined){
                top.data.tableId = getTableId(this.parmsData.tableId);
            }

            let userstr = localStorage.getItem("user");
            if(userstr!=undefined && userstr!=""){
                let user = JSON.parse(userstr);
                let keycode = user.org_id;
                if(keycode!=undefined && keycode!=""){
                    this.keycode = keycode;
                }
            }

            this.init();

        },
        methods: {
            callFunModule(methodName){
                this[methodName]();
            },
            handleChange(field) {//三级联动下拉框改变事件 只保存最后一级
                let values = this.searchInputDtos[field].value;
                let vstr = values[values.length-1];
                this.searchInputDtos[field].value = ""+vstr;
                return true;
            },
            init() {
                layui.use(['table', 'jquery', 'laydate'], function () {
                    table = layui.table;
                    $ = layui.$ //重点处
                    var laydate = layui.laydate;


                    //查询自定义设置的数据
                    postBody("/admin/api/DataManagementController/getCustomFields", {tableId: top.data.tableId,mapdata:top.data.treeNodeObj}, function (res) {
                        let listColumn = res.data.listColumn;
                        listColumn.unshift({checkbox: true});
                        for(let i=0;i<listColumn.length;i++){
                            if(listColumn[i].col_style == "4"){//判断如果是图片，则显示图片并打开
                                let field_tem = listColumn[i].field;
                                listColumn[i].templet = function (d){
                                    let divhtml = "";
                                    if(d[field_tem] == ""){
                                        return divhtml;
                                    }
                                    let openurl = "/admin/html/dataManagement/img_show.html?img="+d[field_tem];
                                    let durls = d[field_tem].split(",");
                                    for(let b=0;b<durls.length;b++){
                                        divhtml = divhtml+"<span style='margin: 0 5px;'><img src=\""+durls[b]+"\" width=\"30px\" height=\"30px\"/></span>"
                                    }
                                    let spanclick = "top.f_layer_open_get('"+openurl+"','80%','70%','',null,'图片查看',null)";
                                    return "<span onclick="+spanclick+">"+divhtml+"</span>";
                                };
                            }

                        }
                        //设置按钮
                        vm.buttons = res.data.buttons;
                        //渲染查询区域
                        vm.listSearch = res.data.listSearch;
                        //动态加载三级联动
                        for(let itemKey in vm.listSearch){
                            let itemDto = vm.listSearch[itemKey];
                            if(itemDto.type == "11"){
                                vm.cascaderProps[itemDto.key] = {//三级联动动态加载
                                    lazy: true,
                                    checkStrictly : true,
                                    async lazyLoad (node, resolve){
                                        console.log("node:",node);
                                        let pid = "0000";
                                        if(node.level != '0'){
                                            pid = node.data.value;
                                        }
                                        const res = await listAdmin(itemDto.data_zygl_id,"id",{pid:pid});
                                        let nodes = [];
                                        let nodesList = res.data;
                                        for(let c=0;c<nodesList.length;c++){
                                            nodes.push({value:nodesList[c][itemDto.select_v],label:nodesList[c][itemDto.select_text],level:1});
                                        }

                                        resolve(nodes);
                                    }
                                }
                            }
                        }
                        vm.searchInputDtos = res.data.listSearch;
                        vm.mapzygl = res.data.mapzygl;

                        //初始化日期框
                        vm.$nextTick(function () {
                            $("[t=date]").each(function (index, element) {
                                let name = $(this).attr("name");
                                let id = $(this).attr("id");
                                let dt = "start";
                                if (id.endsWith("end")) {
                                    dt = "end";
                                }
                                //日期常规用法
                                laydate.render({
                                    elem: '#' + id,
                                    done: function (value, date, endDate) {
                                        vm.searchInputDtos[name].searchTypeForDateDto[dt] = value;//设置vue数据对象的值
                                    }
                                });
                            });

                            $("[t=datetime]").each(function (index, element) {
                                let name = $(this).attr("name");
                                let id = $(this).attr("id");
                                let dt = "start";
                                if (id.endsWith("end")) {
                                    dt = "end";
                                }
                                laydate.render({
                                    elem: '#' + id,
                                    type: 'datetime',
                                    done: function (value, date, endDate) {
                                        vm.searchInputDtos[name].searchTypeForDateDto["end"] = value;//设置vue数据对象的值
                                    }
                                });
                            });

                            let listother = {};
                            copy(top.data.treeNodeObj,listother);
                            copy({ids:top.data.param.ids},listother);
                            top.data.listother = listother;

                            //执行渲染
                            table.render({
                                id: "idTest",
                                elem: '#demo' //指定原始表格元素选择器（推荐id选择器）
                                ,
                                height: 'full-160' //容器高度
                                ,
                                cols: [listColumn] //设置表头
                                ,
                                url: wwwurl+"/admin/api/DataManagementController/list"
                                ,
                                where: {
                                    orderBy: top.data.orderCol,
                                    tableId: top.data.tableId,
                                    searchInputDtos: vm.searchInputDtos,
                                    other: listother
                                }
                                ,
                                contentType: 'application/json'
                                ,
                                method: "post"
                                ,
                                page: true
                                ,
                                limit: 50
                                ,
                                // toolbar: '.layui-btn-group'
                                // ,
                                even:true,
                                request: {
                                    pageName: 'pageNumber' //页码的参数名称，默认：page
                                    , limitName: 'pageSize' //每页数据量的参数名，默认：limit
                                },
                                headers: {
                                    token: localStorage.getItem("token")
                                }
                                ,
                                parseData: function (res) {
                                    return {
                                        "code": "0", //解析接口状态
                                        "msg": res.msg, //解析提示文本
                                        "count": res.data.total, //解析数据长度
                                        "data": res.data.rows //解析数据列表
                                    };
                                }
                                //,…… //更多参数参考右侧目录：基本参数选项
                            });

                            //复选枉单击事件
                            table.on('checkbox(test)', function(obj){
                                let index = obj.tr.data('index');
                                let tableData = table.cache.idTest;//menu 是表格id
                                let trHasClass = obj.tr.hasClass('layui-table-click');

                                //循环判断class,选中checkbox
                                layui.each(tableData, function (i, item) {
                                    if (trHasClass == true) {
                                        if (index == i) {
                                            item.LAY_CHECKED = true;
                                        }
                                    } else {
                                        if (index == i) {
                                            item.LAY_CHECKED = false;
                                        }
                                    }
                                });
                            });


                            //监听行双击事件
                            table.on('rowDouble(test)', function (obj) {
                                let item = $("[up=true]").attr("item");
                                item = JSON.parse(item);
                                let checkStatus = {data:[obj.data],isAll: false};
                                vm.f_upex(item,obj.data.id,checkStatus);
                            });


                            //监听行单击事件
                            table.on('row(test)', function (obj) {
                                console.log(obj)
                                //动态添加背景色
                                if (obj.tr.hasClass('layui-table-click')) {
                                    obj.tr.removeClass('layui-table-click');    //删除背景色和
                                    obj.tr.find('.layui-form-checkbox').removeClass('layui-form-checked');//取消复选框选中样式
                                } else {
                                    obj.tr.addClass('layui-table-click');
                                    obj.tr.find('.layui-form-checkbox').addClass('layui-form-checked');  //设置复选框选中样式
                                }

                                var index = obj.tr.data('index');
                                var tableData = table.cache.idTest;//menu 是表格id
                                var trHasClass = obj.tr.hasClass('layui-table-click');

                                //循环判断class,选中checkbox
                                layui.each(tableData, function (i, item) {
                                    if (trHasClass == true) {
                                        if (index == i) {
                                            item.LAY_CHECKED = true;
                                        }
                                    } else {
                                        if (index == i) {
                                            item.LAY_CHECKED = false;
                                        }
                                    }
                                });
                            });
                        });
                    })
                });

            },
            f_search_advanced() {
                let btn = {
                    btn: ['确定', '取消']
                    , yes: function (index, layero) {
                        //按钮【按钮一】的回调
                        let win = getTopIframe(layero);
                        let data = win.getData();
                        console.log(data);
                        table.reload("idTest", {
                            page: {
                                curr: 1 //重新从第 1 页开始
                            },
                            where: {orderBy: top.data.orderCol, tableId: top.data.zygl_id, searchInputDtos: data,listother:top.data.listother,other:top.data.listother}
                        });
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                };
                top.f_layer_open_get("/admin/html/dataManagement/advancedRetrieval.html", "40%", "60%", function () {

                }, btn, "高级检索")
            },
            f_set_list() {
                let btn = {
                    btn: ['关闭']
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                };
                top.data.custom = "IS_LIST";
                top.f_layer_open_get("/admin/html/dataManagement/custom_list.html", "80%", "65%", function () {

                }, btn, "列表自定义")
            },
            f_set_order(){
                let btn = {
                    btn: ['保存','关闭'],
                    yes: function (index, layero){
                        var win = getTopIframe(layero);
                        let data = win.getData();
                        let i = top.layer.load();
                        postBody("/admin/api/SortCustomManagementController/saveCustomSortData", {list:data}, function (res) {
                            top.layer.close(i);
                            top.alert(res.msg);
                            table.reload("idTest", {});
                        })
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                };
                top.f_layer_open_get("/admin/html/dataManagement/custom_order.html?tableId="+top.data.zygl_id, "60%", "65%", function () {

                }, btn, "排序自定义")
            },
            f_set_input() {
                let btn = {
                    btn: ['关闭']
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                };
                top.data.custom = "IS_INPUT";
                top.f_layer_open_get("/admin/html/dataManagement/custom_search.html", "80%", "65%", function () {

                }, btn, "录入自定义")
            },
            f_search_custom() {
                let btn = {
                    btn: ['关闭']
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                };
                top.data.custom = "IS_SEARCH";
                top.f_layer_open_get("/admin/html/dataManagement/custom_search.html", "80%", "65%", function () {

                }, btn, "自定义搜索")
            },
            f_search_simp() {
                table.reload("idTest", {
                    where:{orderBy:top.data.orderCol,tableId:top.data.tableId,searchInputDtos:vm.searchInputDtos,listother:top.data.listother,other:top.data.listother}
                });
            },
            async f_exp(o){
                let btn = {
                    btn: ['关闭']
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                };
                let item = $(o).attr("item");
                console.log("item_add:"+item);
                item = JSON.parse(item);
                const res = await postBody("/admin/api/DataManagementController/expExcel",{searchInputDtos:vm.searchInputDtos,tableId:item.custom_data_zygl_id});
                top.alert(res.msg);
                top.f_layer_open_get("/admin/html/dataManagement/expexcel-getpro.html", "60%", "25%", function () {

                }, btn, "数据导出")
            },
            //读卡充值
            dukachongzhi(){
                let btn = {
                    btn: ['确定', '取消']
                    , yes:async function (index, layero) {
                        //按钮【按钮一】的回调
                        let win = getTopIframe(layero);
                        let issubmit = win.verification();
                        if (!issubmit) {
                            return false;
                        }
                        let data = win.getData();

                        //获取本地调用接口地址
                        let localurl = Object.values(data)[0]["dyjk"];
                        if(localurl == null || localurl == ""){
                            top.alert("该卡种没有设置读卡接口");
                            return ;
                        }

                        let pdata = JSON.parse(Object.values(data)[0]["parms"]);
                        let i = top.load();
                        const res = await postBodyNotHeaders(localurl,pdata);
                        /*const res = {
                            "code": 200,
                            "data": {
                                "CardType": 4,
                                "PlugInFlag": 0,
                                "TypeName": "用户卡",
                                "BuyValue": 0.0,
                                "SysCode": "25196",
                                "AreaCode": null,
                                "MeterID": "857"
                            }
                        };*/
                        if(res.code!=200){
                            top.layer.close(i);
                            top.alert(res.msg);
                            return;
                        }

                        if(res.data.PlugInFlag == "1"){
                            top.layer.close(i);
                            top.alert("水卡上次未刷表，请刷表后再购水！");
                            return;
                        }

                        //开始充值
                        vm.chongzhi(res.data);
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                };
                top.f_layer_open_get("/admin/html/inputCustom/index.html?tableId="+getTableId("900"), "40%", "45%", function () {

                }, btn, "选择卡片",{});
            },
            //开始充值
            async chongzhi(resdata){
                let i = top.load();
                //查詢客戶信息
                const getresdata = await postWebCustom(getTableId("902"),{user_code:resdata.MeterID});
                top.layer.close(i);
                if(getresdata.code == 0){
                    top.alert(getresdata.msg);
                    return;
                }
                top.layer.closeAll();

                let btn = {
                    btn: ['确定', '取消']
                    , yes:async function (index, layero) {
                        //按钮【按钮一】的回调
                        let win = getTopIframe(layero);
                        let issubmit = win.verification();
                        if (!issubmit) {
                            return false;
                        }
                        let data = win.getData();
                        console.log(data);
                        let i = top.load();
                        //获取本地调用购买接口地址
                        let khid = Object.values(data)[0]["id"];
                        let gml = Object.values(data)[1]["gml"];
                        const reslocal = await postWebCustom(getTableId("907"),{"khid":""+khid,bugvalue:""+gml});
                        console.log(reslocal);
                        if(reslocal.code == 0){
                            top.layer.close(i);
                            top.alert(reslocal.msg);
                            return ;
                        }
                        let localurl = reslocal.data["dyjk"];
                        if(localurl == null || localurl == ""){
                            top.layer.close(i);
                            top.alert("该卡种没有设置充值接口");
                            return ;
                        }

                        let pdata = JSON.parse(reslocal.data["parms"]);

                        const res = await postBodyNotHeaders(localurl,pdata);
                        if(res.code!=200){
                            top.layer.close(i);
                            top.alert(res.msg);
                            return;
                        }

                        //卡片充值成功后保存数据到数据库
                        const czres = await postWebCustom(getTableId("905"),{jsontext:JSON.stringify(data)});
                        if(czres.code == 0){
                            top.layer.close(i);
                            top.alert(czres.msg);
                            return;
                        }
                        top.layer.closeAll();
                        top.alert(czres.msg);
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                };

                top.f_layer_open_get("/admin/html/module/shuiwu/kehu/jiaofeiInput.html?tableId="+getTableId("901"), "80%", "80%", function () {

                }, btn, "客户充值",getresdata.data);
            },
            //开户
            async f_add(o) {

                let item = $(o).attr("item");
                console.log("item_add:"+item);
                item = JSON.parse(item);
                let checkStatus = table.checkStatus('idTest'); //idTest 即为基础参数 id 对应的值
                let ids = [];
                for (var a = 0; a < checkStatus.data.length; a++) {
                    ids.push(checkStatus.data[a][item.mapzygl.key_name]);
                }
                let other = {
                    ids: "" + ids,
                    treeNode: top.data.treeNodeObj,
                    tableId: item.mapzygl.id,
                    input_id:item.mapzygl.input_id,
                    listother:top.data.listother,
                    type:"add"
                }
                top.data.other = other;
                top.data.param = other;
                top.data.buttonsItem = item.mapzygl;

                let btn = {
                    btn: ['确定','关闭']
                    , yes: async function (index, layero) {
                        console.log(layero);
                        //按钮【按钮一】的回调
                        var win = getTopIframe(layero);
                        let issubmit = win.verification();
                        if (!issubmit) {
                            return false;
                        }
                        let data = win.getData();
                        data.id = "";
                        let i = top.load();
                        //调用开户接口
                        let kplx = Object.values(data)[1]["kplx"];
                        const khlocal = await postWebCustom(getTableId("906"),{kid:kplx});
                        if(khlocal.code == 0){
                            top.layer.close(i);
                            top.alert(khlocal.msg);
                            return ;
                        }
                        const reskh = await postBodyNotHeaders(khlocal.data.dyjk,JSON.parse(khlocal.data.parms));
                        if(reskh.code != 200){
                            top.layer.close(i);
                            top.alert(reskh.msg);
                            return ;
                        }

                        //开始保存数据库
                        let map1 = Object.values(data)[1];
                        map1["sys_code"] = khlocal.data.sysCode;
                        map1["user_code"] = khlocal.data.userCode;
                        let key1 = Object.keys(data)[1];
                        data[key1] = map1;
                        other.type = "add";
                        postBody("/admin/api/DataManagementController/add", {
                            tableId: item.mapzygl.id,
                            mapdata: data,
                            other: other
                        }, function (res) {
                            if(res.data != undefined){
                                vm.dataid = res.data.id;
                            }
                            top.layer.close(i);
                            top.alert(res.msg);
                            table.reload("idTest", {});
                        })
                    }
                    ,btn2:function (index,layero){
                        console.log("关闭按钮");
                    }
                };

                let inputurl = "/admin/html/dataManagement/input.html";
                if (item.mapzygl.url != "") {
                    inputurl = item.mapzygl.url;
                }else {
                    if(item.is_input == "1"){
                        inputurl = "/admin/html/dataManagement/input.html";
                    }
                    if(item.is_input == "2"){
                        top.data.zygl_id = item.custom_data_zygl_id;
                        top.data.tableId = item.custom_data_zygl_id;
                        top.data.orderCol = "id";
                        inputurl = "/admin/html/dataManagement/list.html";
                    }
                    if(item.mapzygl.input_id != ""){
                        top.data.zygl_id = item.custom_data_zygl_id;
                        top.data.tableId = item.custom_data_zygl_id;
                        inputurl = "/admin/html/inputCustom/index.html";
                    }
                }

                top.data.input_id = item.mapzygl.input_id;
                let width = item.mapzygl.input_width;
                let height = item.mapzygl.input_height;
                const resq = await postBody("/admin/api/DataManagementController/queryDataForId",{tableId: item.mapzygl.id,other: other,ids:""+ids});
                if(resq.code == 0){
                    top.alert(resq.msg);
                    return;
                }
                top.f_layer_open_get(inputurl, width, height, function () {

                }, btn, "添加数据", resq.data);
            }
            ,f_upex(item,ids,checkStatus){

                let other = {
                    ids: "" + ids,
                    treeNode: top.data.treeNodeObj,
                    tableId: item.mapzygl.id,
                    input_id:item.mapzygl.input_id,
                    listother:top.data.listother,
                    type:"update"
                }

                top.data.other = other;
                top.data.param = other;
                top.data.buttonsItem = item.mapzygl;
                postBody("/admin/api/DataManagementController/queryDataForId", {
                    ids: checkStatus.data[0][item.mapzygl.key_name],
                    tableId: item.mapzygl.id,
                    other: other
                }, function (res) {
                    let btn = {
                        btn: ['确定', '取消']
                        , yes: function (index, layero) {
                            console.log(layero);
                            //按钮【按钮一】的回调
                            var win = getTopIframe(layero);
                            let issubmit = win.verification();
                            if (!issubmit) {
                                return;
                            }
                            console.log(checkStatus);
                            let data = win.getData();
                            let mapdatasubmit = data;
                            mapdatasubmit.id = checkStatus.data[0].id;
                            let i = top.layer.load();
                            postBody("/admin/api/DataManagementController/update", {
                                tableId: item.mapzygl.id,
                                mapdata: mapdatasubmit,
                                other: other
                            }, function (res) {
                                top.layer.close(i);
                                top.alert(res.msg);
                                table.reload("idTest", {});
                            })
                        }
                        , btn2: function (index, layero) {
                            //按钮【按钮二】的回调
                            //return false 开启该代码可禁止点击该按钮关闭
                        }
                    };
                    let inputurl = "/admin/html/dataManagement/input.html";
                    if (item.mapzygl.url != "") {
                        inputurl = item.mapzygl.url;
                    }else {
                        if(item.is_input == "1"){
                            inputurl = "/admin/html/dataManagement/input.html";
                        }
                        if(item.is_input == "2"){
                            top.data.zygl_id = item.custom_data_zygl_id;
                            top.data.tableId = item.custom_data_zygl_id;
                            top.data.orderCol = "id";
                            inputurl = "/admin/html/dataManagement/list.html";
                        }
                        if(item.mapzygl.input_id != ""){
                            top.data.zygl_id = item.custom_data_zygl_id;
                            top.data.tableId = item.custom_data_zygl_id;
                            inputurl = "/admin/html/inputCustom/index.html";
                        }
                    }

                    top.data.input_id = item.mapzygl.input_id;
                    let width = item.mapzygl.input_width;
                    let height = item.mapzygl.input_height;
                    if(res.code == 0){
                        top.alert(res.msg);
                        return;
                    }
                    top.f_layer_open_get(inputurl, width, height, function () {

                    }, btn, "修改数据", res.data);
                })
            }
            , f_update(o) {
                var checkStatus = table.checkStatus('idTest'); //idTest 即为基础参数 id 对应的值
                if (checkStatus.data.length != 1) {
                    top.alert("只能选择一条记录进行修改");
                    return;
                }
                console.log(checkStatus)

                let item = $(o).attr("item");
                item = JSON.parse(item);

                let ids = [];
                for (var a = 0; a < checkStatus.data.length; a++) {
                    ids.push(checkStatus.data[a][item.mapzygl.key_name]);
                }
                this.f_upex(item,ids,checkStatus);
            }
            , f_delete(o) {
                let item = $(o).attr("item");
                item = JSON.parse(item);
                var checkStatus = table.checkStatus('idTest'); //idTest 即为基础参数 id 对应的值
                if (checkStatus.data.length == 0) {
                    top.alert("请选择记录进行删除");
                    return;
                }
                let ids = [];
                for (var a = 0; a < checkStatus.data.length; a++) {
                    ids.push(checkStatus.data[a][item.mapzygl.key_name]);
                }

                layer.confirm('确定要永久删除吗？', {
                    btn: ['确定', '取消'] //可以无限个按钮
                }, function (index, layero) {
                    let other = {
                        ids: "" + ids,
                        treeNode: top.data.treeNodeObj,
                        tableId: item.mapzygl.id,
                        listother:top.data.listother
                    }
                    top.data.other = other;
                    postBody("/admin/api/DataManagementController/delete", {
                        ids: "" + ids,
                        tableId: item.mapzygl.id,
                        other: other
                    }, function (res) {
                        top.alert(res.msg);
                        table.reload("idTest", {});
                        layer.close(index);
                    })
                }, function (index) {
                    //按钮【按钮二】的回调
                });


            },
            f_post_confirm(o){
                let item = $(o).attr("item");
                item = JSON.parse(item);
                if(item.is_confirm == "1"){
                    layer.confirm('确定要执行此操作吗？', {
                        btn: ['确定', '取消'] //可以无限个按钮
                    }, function (index, layero) {
                        layer.close(index);
                        vm.f_post(o);
                    }, function (index) {
                        //按钮【按钮二】的回调
                    });
                }else {
                    vm.f_post(o);
                }

            }
            , f_post(o) {//自定义数据接口
                var checkStatus = table.checkStatus('idTest'); //idTest 即为基础参数 id 对应的值
                var ids = [];
                for (var a = 0; a < checkStatus.data.length; a++) {
                    ids.push(checkStatus.data[a][top.data.treeObj.key_name]);
                }

                let item = $(o).attr("item");
                item = JSON.parse(item);
                top.data.buttonsItem = item.mapzygl;
                if (item.is_input != 0) {
                    top.data.zygl_id = item.custom_data_zygl_id;
                    let param = {
                        treeNode: top.data.treeNodeObj,
                        ids: "" + ids,
                        tableId: item.custom_data_zygl_id,
                        mapdata:{searchInputDtos:vm.searchInputDtos}
                    }
                    top.data.param = param;
                    let i = top.load();
                    postBody("/admin/api/DataManagementController/customGetFormData", param, function (res) {
                        top.layer.close(i);
                        if(res.code == "0"){
                            top.alert(res.msg);
                            return ;
                        }

                        let btn = {
                            btn: ['确定', '取消']
                            , yes: function (index, layero) {
                                //按钮【按钮一】的回调
                                var win = getTopIframe(layero);
                                let issubmit = win.verification();
                                if (!issubmit) {
                                    return;
                                }
                                let data = win.getData();
                                data.listother = top.data.listother;
                                data["searchInputDtos"] = vm.searchInputDtos;
                                let i = top.layer.load();
                                let psubmit = {
                                    treeNode: top.data.treeNodeObj,
                                    ids: "" + ids,
                                    tableId: item.custom_data_zygl_id,
                                    mapdata: data
                                }
                                top.data.param = param;
                                postBody("/admin/api/DataManagementController/customPostData", psubmit, function (res) {
                                    top.layer.close(i);
                                    top.alert(res.msg);
                                    table.reload("idTest", {});
                                })
                            }
                            , btn2: function (index, layero) {
                                //按钮【按钮二】的回调
                                //return false 开启该代码可禁止点击该按钮关闭
                            }
                        };
                        let openurl = item.mapzygl.url;
                        if (openurl == "") {
                            if(item.is_input == "1"){
                                openurl = "/admin/html/dataManagement/input.html";
                            }
                            if(item.is_input == "2"){
                                top.data.zygl_id = item.custom_data_zygl_id;
                                top.data.tableId = item.custom_data_zygl_id;
                                top.data.orderCol = "id";
                                openurl = "/admin/html/dataManagement/list.html";
                            }

                        }

                        if(item.mapzygl.input_id != ""){
                            openurl = "/admin/html/inputCustom/index.html";
                            top.data.zygl_id = item.custom_data_zygl_id;
                            top.data.tableId = item.custom_data_zygl_id;
                            console.log("inputid",top.data.tableId)
                        }

                        top.data.input_id = item.mapzygl.input_id;
                        let width = item.mapzygl.input_width;
                        let height = item.mapzygl.input_height;
                        top.f_layer_open_get(openurl, width, height, function () {
                            top.data.zygl_id = top.data.tableId;
                        }, btn, "提交数据", res.data);
                    })

                } else {
                    let psubmit = {
                        treeNode: top.data.treeNodeObj,
                        ids: "" + ids,
                        tableId: item.custom_data_zygl_id,
                        mapdata:{searchInputDtos:vm.searchInputDtos}
                    }
                    let i = top.layer.load();
                    postBody("/admin/api/DataManagementController/customPostData", psubmit, function (res) {
                        top.layer.close(i);
                        top.alert(res.msg);
                        table.reload("idTest", {});
                    })
                }
            }

        }
    })



    //验证必填项
    function verification() {

        return true;
    }

    function getData() {
        var checkStatus = table.checkStatus('idTest'); //idTest 即为基础参数 id 对应的值
        if (checkStatus.data.length == 0) {
            top.alert("请选择记录进行操作！");
            return;
        }
        let ids = [];
        for (var a = 0; a < checkStatus.data.length; a++) {
            ids.push(checkStatus.data[a]["id"]);
        }
        return {ids:""+ids};
    }

    function setData(data) {
    }
</script>

</body>
</html>
